home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / SHARED.DIR / 03109_Script_SSVRObject Scripts < prev    next >
Text File  |  1996-04-01  |  6KB  |  189 lines

  1. on SSVR_Drag
  2.   lockCursors
  3.   SSVR_SetCursor "drag"
  4.   
  5.   set triggerPixels = 3
  6.   set prevH = the mouseH
  7.   set prevV = the mouseV
  8.   repeat while the mouseDown
  9.     set hOffset = prevH - the mouseH
  10.     set vOffset = prevV - the mouseV
  11.     set hFrameOffset = 0
  12.     set vFrameOffset = 0
  13.     if abs(hOffset) >= triggerPixels then set hFrameOffset = hOffset / triggerPixels
  14.     if abs(vOffset) >= triggerPixels then set vFrameOffset = vOffset / triggerPixels
  15.     if hFrameOffset OR vFrameOffset then
  16.       SSVR_OffsetRowCol vFrameOffset, hFrameOffset
  17.       updateStage
  18.       set prevH = the mouseH
  19.       set prevV = the mouseV
  20.     end if
  21.   end repeat
  22.   
  23.   unlockCursors
  24.   SSVR_UpdateCursors
  25. end
  26.  
  27. on SSVR_Spin direction, framesPerJump
  28.   if voidP(framesPerJump) then set framesPerJump = 1
  29.   
  30.   lockCursors
  31.   
  32.   repeat while the mouseDown
  33.     SSVR_Nudge direction, framesPerJump
  34.     updateStage
  35.   end repeat
  36.   
  37.   unlockCursors
  38.   SSVR_UpdateCursors
  39. end
  40.  
  41. on SSVR_Nudge direction, howMuch
  42.   if direction = "right" then
  43.     SSVR_OffsetRowCol 0, -howMuch
  44.   else if direction = "left" then
  45.     SSVR_OffsetRowCol 0, howMuch
  46.   else if direction = "up" then
  47.     SSVR_OffsetRowCol howMuch, 0
  48.   else if direction = "down" then
  49.     SSVR_OffsetRowCol -howMuch, 0
  50.   end if
  51. end
  52.  
  53. on SSVR_JumpToRowCol newRow, newCol
  54.   set NumCols = getgSSVRMovieProp(#numCols)
  55.   set whichSprite = getgSSVRMovieProp(#sprite)
  56.   set ticksPerFrame = getgSSVRMovieProp(#ticksPerFrame)
  57.   
  58.   setgSSVRMovieProp #Row, newRow
  59.   setgSSVRMovieProp #Col, newCol
  60.   
  61.   -- Note: All the -1s are to correct for 1-based values.
  62.   set newFrame = (((NewRow - 1) * NumCols) + (NewCol - 1))
  63.   set the movietime of sprite whichSprite = newFrame * ticksPerFrame
  64.   
  65.   global gDragging
  66.   if NOT(gDragging) then SSVR_UpdateCursors
  67. end
  68.  
  69. on SSVR_OffsetRowCol offsetRow, offsetCol
  70.   set Col = getgSSVRMovieProp(#Col)
  71.   set NumCols = getgSSVRMovieProp(#numCols)
  72.   set Row = getgSSVRMovieProp(#Row)
  73.   set NumRows = getgSSVRMovieProp(#numRows)
  74.   set whichSprite = getgSSVRMovieProp(#sprite)
  75.   set ticksPerFrame = getgSSVRMovieProp(#ticksPerFrame)
  76.   
  77.   set newRow = Row + offsetRow
  78.   if newRow < 1 then set newRow = 1 -- don't wrap around
  79.   else if newRow > NumRows then set newRow = NumRows -- don't wrap around
  80.   
  81.   set newCol = Col + offsetCol
  82.   if newCol < 1 then set newCol = NumCols -- wrap around
  83.   else if newCol > NumCols then set newCol = 1 -- wrap around
  84.   
  85.   SSVR_JumpToRowCol newRow, newCol
  86. end
  87.  
  88. on SSVR_JumpToStart
  89.   
  90.   set startRow = getgSSVRMovieProp(#startRow)
  91.   set startCol = getgSSVRMovieProp(#startCol)
  92.   
  93.   SSVR_JumpToRowCol startRow, startCol
  94.   
  95.   -- SSVR_SpinToRow startRow
  96.   -- SSVR_SpinToCol startCol
  97.   updateStage
  98. end
  99.  
  100. on SSVR_InitObject whichSprite, firstEdgeSprite, whichCast, numRows, numCols, startRow, startCol
  101.   set L = [:]
  102.   addProp L, #sprite, whichSprite
  103.   addProp L, #firstEdgeSprite, firstEdgeSprite
  104.   addProp L, #numRows, numRows
  105.   addProp L, #numCols, numCols
  106.   set calcTicksPerFrame = ((the duration of cast whichCast) / (numRows * numCols))
  107.   addProp L, #ticksPerFrame, calcTicksPerFrame
  108.   addProp L, #startRow, startRow
  109.   addProp L, #startCol, startCol
  110.   addProp L, #Row, 1 -- the default position
  111.   addProp L, #Col, numCols -- the default position
  112.   return L
  113. end
  114.  
  115. on lockCursors
  116.   global gDragging
  117.   set gDragging = TRUE
  118. end
  119.  
  120. on unlockCursors
  121.   global gDragging
  122.   set gDragging = FALSE
  123.   SSVR_SetCursor "Normal"
  124. end
  125.  
  126. on SSVR_SetCursor which
  127.   global spriteList, cursorList
  128.   
  129.   if which = "Drag" then
  130.     set cursorList = storeAndKillCursors (spriteList)
  131.     cursor [the number of cast "DragCursor", the number of cast "DragCursorMask"]
  132.   else if which = "Normal" then
  133.     restoreCursors spriteList, cursorList
  134.     cursor -1
  135.   end if
  136. end
  137.  
  138. on SSVR_InitCursors
  139.   global gDragging
  140.   set gDragging = FALSE
  141.   
  142.   set whichSprite = getgSSVRMovieProp(#sprite)
  143.   set firstEdgeSprite = getgSSVRMovieProp(#firstEdgeSprite)
  144.   set the cursor of sprite whichSprite = [the number of cast "PawCursor", the number of cast "PawCursorMask"]
  145.   set the cursor of sprite firstEdgeSprite + 2 = [the number of cast "RotateUpCursor", the number of cast "RotateUpCursorMask"]
  146.   set the cursor of sprite firstEdgeSprite + 3 = [the number of cast "RotateDownCursor", the number of cast "RotateDownCursorMask"]
  147.   
  148.   global RotateLeftCursor, RotateRightCursor, ScrollLeftCursor, ScrollRightCursor
  149.   set RotateLeftCursor = the number of cast "RotateLeftCursor"
  150.   set RotateRightCursor = the number of cast "RotateRightCursor"
  151.   set ScrollLeftCursor = the number of cast "ScrollLeftCursor"
  152.   set ScrollRightCursor = the number of cast "ScrollRightCursor"
  153.   
  154.   global firstUpRow, lastDownRow
  155.   set NumRows = getgSSVRMovieProp(#NumRows)
  156.   set firstUpRow = NumRows/3
  157.   set lastDownRow = firstUpRow * 2
  158.   
  159.   global spriteList
  160.   set spriteList = []
  161.   set firstEdgeSprite = getgSSVRMovieProp(#firstEdgeSprite)  
  162.   add spriteList, getgSSVRMovieProp(#Sprite)
  163.   add spriteList, firstEdgeSprite
  164.   add spriteList, firstEdgeSprite+1
  165.   add spriteList, firstEdgeSprite+2
  166.   add spriteList, firstEdgeSprite+3
  167.   
  168.   SSVR_UpdateCursors
  169. end
  170.  
  171. on SSVR_UpdateCursors
  172.   global RotateLeftCursor, RotateRightCursor, ScrollLeftCursor, ScrollRightCursor
  173.   global firstUpRow, lastDownRow
  174.   -- first edge = Left. + 1 = right. + 2 = up. + 3 = down.
  175.   set Row = getgSSVRMovieProp(#Row)
  176.   set firstEdgeSprite = getgSSVRMovieProp(#firstEdgeSprite)
  177.   
  178.   if Row < firstUpRow then
  179.     set the cursor of sprite firstEdgeSprite = [RotateLeftCursor]
  180.     set the cursor of sprite firstEdgeSprite + 1 = [RotateRightCursor]
  181.   else if Row > lastDownRow then
  182.     set the cursor of sprite firstEdgeSprite = [RotateRightCursor]
  183.     set the cursor of sprite firstEdgeSprite + 1 = [RotateLeftCursor]
  184.   else
  185.     set the cursor of sprite firstEdgeSprite = [ScrollLeftCursor]
  186.     set the cursor of sprite firstEdgeSprite + 1 = [ScrollRightCursor]
  187.   end if
  188. end
  189.